package J4_22;

import java.util.Arrays;
import java.util.Scanner;

public class test {
    public static void minMultiply(long a, long b) {
        long min = Math.min(a, b);
        long max = Math.max(a, b);
        if (max % min == 0) {
            System.out.println(max);
            return;
        }
        long i = max / min + 1;
        while (true) {
            long tmp = (long) max * i;
            if (tmp%min==0) {
                System.out.println(tmp);
                return;
            }
            i++;
        }
    }
    public int MLS (int[] arr) {
        Arrays.sort(arr);
        int n = arr.length;
        int[] dp = new int[n];
        dp[0] = 1;
        int max = 1;
        for (int i = 1; i < n; i++) {
            if (arr[i] == arr[i-1]+1) {
                dp[i] = dp[i-1] + 1;
                max = Math.max(max,dp[i]);
            }else if (arr[i] == arr[i-1]){
                dp[i] = dp[i-1];
            }else {
                dp[i] = 1;
            }
        }
        return max;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int[][] arr = new int[a][b];
        for (int i = 0; i < a; i++) {
            char[] ch1 = in.next().toCharArray();
            for (int j = 0; j < b; j++) {
                char ch = ch1[j];
                if (ch=='l') {
                    arr[i][j] = 4;
                } else if(ch=='o') {
                    arr[i][j] = 3;
                } else if (ch=='v') {
                    arr[i][j] = 2;
                } else if (ch=='e') {
                    arr[i][j] = 1;
                }
            }
        }
        int[][] dp = new int[a+1][b+1];
        for (int i = 1; i <= a; i++) {
            for (int j = 1; j <= b; j++) {
                dp[i][j] = Math.max(dp[i-1][j],dp[i][j-1]) + arr[i-1][j-1];
            }
        }
        System.out.println(dp[a][b]);

    }
}
